﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace ExamManagementSystem
{
    public partial class AddSubjectForm : Form
    {
        public AddSubjectForm()
        {
            InitializeComponent();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            String SubjectName = this.txtSubjectName.Text.ToString();
            if (SubjectName == null)
                MessageBox.Show("科目名称不能为空！");
            else
            {
                SqlConnection conn = DBHelper.connection;
                conn.Open();
                String strSql = "insert into mySubject values('" + SubjectName + "')";
                SqlCommand cmd = new SqlCommand(strSql,conn);
                if ((int)cmd.ExecuteNonQuery() > 0)
                    MessageBox.Show("添加成功");
                else
                    MessageBox.Show("添加失败");
                this.txtSubjectName.Text = "";
                conn.Close();
            }
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
